package com.jweb.framework.core.ex;

import org.springframework.validation.Errors;
import org.springframework.validation.ObjectError;

import com.jweb.framework.core.CoreException;


public class ValidationException extends CoreException {

	/**
	 * 
	 */
	private static final long serialVersionUID = -8756450628906945401L;
	
	private Errors errors ;
	
	public ValidationException(String str){
		super(str);
	}
	
	public ValidationException(String str , Throwable throwable){
		super(str , throwable);
	}
	
	public ValidationException(String str1 , String str2){
		super(str1 , str2);
	}
	
	public ValidationException(String str1 , String str2 , Throwable throwable){
		super(str1 , str2 , throwable);
	}
	
	public Errors getErrors(){
		return this.errors ;
	}
	
	public void setErrors(Errors errors){
		this.errors = errors ;
	}
	
	public String getMessage(){
		if(this.errors == null){
			return super.getMessage();
		}
		StringBuffer sb = new StringBuffer(super.getMessage());
		for(ObjectError e : this.errors.getAllErrors()){
			sb.append("\n");
			sb.append(e);
		}
		return sb.toString();
	}
	
}
